﻿(function (id) {
    (function () {
        Array.prototype.map = Array.prototype.map || function (func) {
            if (typeof func != 'function') throw new Error('arg must array');
            for (var i = 0, outList = []; i < this.length; i++) outList[i] = func(this[i], i, this);
            return outList;
        };
    })();
    window.WSF = window.WSF || {};
    WSF.loadFuncList = [];
    WSF._runList = [];
    WSF.load = function (done) {
        if (typeof done == 'function') { WSF._runList.push(done); WSF.loadFuncList.push(done) }
        if (document.readyState == "complete") {
            for (var k in WSF._runList) WSF._runList.pop()();
        } else {
            window.setTimeout(arguments.callee, 100);
        }
    };
    WSF.util = WSF.util || {
        resolveTemplate: function () {
            for (var i = 1, source = arguments[0]; i < arguments.length; i += 2) source = source.replace(new RegExp('\{\{' + arguments[i] + '\}\}', 'g'), arguments[i + 1]);
            return source;
        },
        addEvent: function (obj, eventName, callback) {
            if (obj.attachEvent) obj.attachEvent("on" + eventName, callback);
            else if (obj.addEventListener) obj.addEventListener(eventName, callback, false);
        },
        numberStr: function (number) {
            if (!arguments.length) number = 0;
            return number < 10 ? '0' + number : number.toString();
        },
        getPosAry: function () {
            var outList = [], offset = 0;
            for (var i = 0; i < 3; i++) {
                for (var j = 0; j < 3; j++) {
                    outList[offset] = [document.documentElement.clientWidth / 3 * j, document.documentElement.clientHeight / 3 * i];
                    offset++;
                }
            }
            return outList;
        },
        setDef: function (varAry, args, length) {
            if (!length) length = varAry.length;
            for (var i = 0; i < length; i++) varAry[i] = varAry[i] || args[i];
        }, getPosStyle: function (config) {
            if (config.typeid !== '1') return '';
            var opt = {};
            opt.positionid = config.positionid || '0';
            opt.distince = config.distince || 0;
            opt.width = config.width;
            opt.height = config.height;
            var styleObj = { 'left': '', 'top': '', 'right': '', 'bottom': '' };
            /*百分比*/
            switch (opt.positionid) {
                case '1':
                    styleObj.left = 0;
                    styleObj.top = (opt.distince + 0);
                    break;
                case '2':
                    if (opt.width && opt.height) {
                        styleObj.top = (opt.distince + 0);
                        styleObj.left = '50%';
                        styleObj["margin-left"] = ~~(-opt.width / 2)+'px';
                    } else {
                        styleObj.top = (opt.distince + 0);
                        styleObj['margin'] = 'auto';
                    }
                    break;
                case '3':
                    styleObj.top = (opt.distince + 0);
                    styleObj.right = 0;
                    break;
                case '4':
                    styleObj.top = (opt.distince + 30);
                    styleObj.left = 0;
                    break;
                case '5':
                    if (opt.width && opt.height) {
                        styleObj.top = (opt.distince + 50);
                        styleObj.left = '50%';
                        styleObj["margin"] = ~~(-opt.height / 2)+'px '+~~(-opt.width/2)+'px';
                    } else {
                        styleObj.top = (opt.distince + 30);
                        styleObj['margin'] = 'auto';
                    }
                    break;
                case '6':
                    styleObj.top = (opt.distince + 30);
                    styleObj.right = 0;
                    break;
                case '7':
                    styleObj.bottom = (opt.distince + 0);
                    styleObj.left = 0;
                    break;
                case '8':
                    styleObj.bottom = (opt.distince + 0);
                    if (opt.width && opt.height) {
                        styleObj.left = '50%';
                        styleObj["margin"] = ~~(-opt.height / 2) + 'px ' + ~~(opt.width / 2)+'px';
                    } else {
                        styleObj['margin'] = 'auto';
                    }
                    break;
                case '9':
                    styleObj.bottom = (opt.distince + 0);
                    styleObj.right = 0;
                    break;
                default:; return ''; break;
            }
            var outText = '';
            for (var k in styleObj) {
                if (styleObj[k] > 0) styleObj[k] += '%';
                if (styleObj[k] !== '') outText += k + ':' + styleObj[k] + ';';
            }
            return outText;
        }
    };
    var script = document.createElement('script');
    script.type = 'text/javascript', script.async = true, script.src = '//{{=uri}}/MiniJs.aspx?p=' + encodeURIComponent(window.location.href) + '&r=' + encodeURIComponent(document.referrer) + '&id=' + encodeURIComponent(id) + '&_=' + Date.now();
    if (document.getElementsByTagName('body')[0]) document.getElementsByTagName('body')[0].appendChild(script);
    else document.getElementsByTagName('head')[0].appendChild(script);
})('{{id}}');
